<?php

namespace Admin\Controller;

use Think\Controller;

class TradeController extends Controller
{
    public function index()
    {
        $info = M('Trade')->field('userid,num,price,money_type,pay_type,type,trade_id,deal,order_status,evaluatbuyer,evaluatseller')->select();

        foreach ($info as $k => $v) {
            $username = M('User')->where(array(
                'id' => $v['userid']
            ))->getField('username');

            $info[$k]['username'] = $username;

            $tradename = M('User')->where(array(
                'id' => $v['trade_id']
            ))->getField('username');

            $info[$k]['tradename'] = $tradename;

            $moneytype = M('MoneyType')->where(array(
                'id' => $v['money_type']
            ))->getField('zh_name');

            $info[$k]['money_zh_name'] = $moneytype;
        }


        $this->ajaxReturn($info, 'JSON');
    }
}